package com.gaojunxiang.controller;

import com.gaojunxiang.domain.User;
import com.gaojunxiang.service.UserService;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    //将UserService注入到注册中心
    @Reference
    private UserService userService;
    @GetMapping("/{id}")
    public User findById(@PathVariable int id){
       return userService.findById(id);
    }
    @PostMapping("/save")
    public Boolean save(User user){
        return userService.save(user);
    }
    @DeleteMapping("/{id}")
    public Boolean delete(@PathVariable int id){
        return userService.delete(id);
    }
    @PutMapping("/update")
    public Boolean findById(User user){
        return userService.update(user);
    }
    @GetMapping("/login/{username}/{password}")
    public User login(@PathVariable String username,@PathVariable String password){
        return userService.login(username,password);
    }
    @GetMapping("/findAll/{currentPage}/{pageSize}")
    public PageInfo<User> findAll(@PathVariable int currentPage, @PathVariable int pageSize){
        return userService.findAll(currentPage,pageSize);
    }
}
